#include <windows.h>
#include <iostream>
#include "debug.h"

dkim::Debug::Debug(void)
{
	AllocConsole();
}

dkim::Debug::~Debug(void)
{
	FreeConsole();
}

bool dkim::Debug::putString(std::string string, dkim::MessageType messageType)
{
	DWORD lengthOfChar;
	char *notice = "";
	char *server = ">> ";
	char *client = "<< ";
	std::string selected;

	if(messageType == dkim::MessageType::notice)
		selected = notice;
	else if(messageType == dkim::MessageType::server)
		selected = server;
	else if(messageType == dkim::MessageType::client)
		selected = client;
	else
		return false;

	selected = selected + string + "\n";

	if(!WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), selected.c_str(),
		selected.size(), &lengthOfChar, NULL))
	{
		return false;

	}
	else
	{
		return true;
	}
}